<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./vue.js"></script>
  <style>
    .v-enter,
    .v-leave-to {
      opacity: 0;
    }
    .v-enter-active,
    .v-leave-active {
      transition: opacity 1s;
    }
    .v-enter-to,
    .v-leave {
      opacity: 1;
    }

    .guoji-enter,
    .guoji-leave-to {
      position: absolute;
      left: -100%;
    }
    .guoji-enter-active,
    .guoji-leave-active {
      position: absolute;
      transition: left 1s;
    }
    .guoji-enter-to,
    .guoji-leave {
      position: absolute;
      left: 0;
    }

    
  </style>
</head>
<body>
  <div id="app">
    <button @click="news = 'guonei'">国内新闻</button>
    <button @click="news = 'guoji'">国际新闻</button>
    <div>
      <!-- 没有name属性的过度应用的是全局的v-开头的class -->
      <!-- mode属性可以指定过度模式： out-in指的是先消失，消失之后新的组件在进来 -->
      <transition mode="out-in">
        <component :is="news"></component>
      </transition>
      <!-- 加了name属性过度应用的就是guoji-开头的class -->
      <transition name="guoji">
        <component :is="news"></component>
      </transition>
    </div>
  </div>
  <script>

    const guonei = {
      template: '<h3>cctv国内新闻</h3>'
    }
    const guoji = {
      template: '<h3>international news</h3>'
    }
   
    const app = new Vue({
      el: '#app',
      data: {
        news: 'guoji'
      },
      components: {
        guonei,
        guoji
      }
    })
  </script>
</body>
</html>
